<?php
namespace app\index\controller;
use think\Controller;
use app\common\controller\HomeBase;
use think\db;
//前台首页
class Index extends HomeBase
{
    public function index()
    {	
    	//查找业务的数据
    	  	
    	  $ywjs=db('category')->where('pid','=',0)->where('link','ywjs')->find();
    	 
	      $this->assign('ywjs',$ywjs);
//	      halt($ywjs);
	      //调取业务的子栏目数据
	      $yw=db('category')->order('sort asc')->where('link','ywjs')->where('pid','>',0)->select();
	     
	      foreach($yw as $k=>$v){
	      	
	      	  $yw[$k]['pics']=db('article')->where('cid',$v['cid'])->value('thumb');
	      	
	      }
//	      halt($yw);
	      $this->assign('yw',$yw);
//	      halt($son);
	      
	      //查找新闻中心的数据
    	  $xwzx=db('category')->where('pid','=',0)->where('link','xwzx')->find();
    	 
	      $this->assign('xwzx',$xwzx);
	      
	      //查找公司简介的数据
    	  $gsjj=db('category')->where('pid','=',0)->where('link','gsjj')->find();
    	  $this->assign('gsjj',$gsjj);
    	  
    	  //找子集
    	   $cids=$this->getSon(db('category')->order('sort asc')->select(),$gsjj['cid']);
		    	if(!empty($cids)){
		    		foreach($cids as $k=>$v){
		    		$arr[]=db('category')->where('cid',$v)->find();
		    	   }
		    	   $cid=$cids[0];
		    	   $oneData=db('article')->where('cid',$cid)->find();
    	       }
//  	   halt($oneData);
    	  $this->assign('oneData',$oneData);
	      
	    
	    
	    
	    //商务合作
	    $link=db('link')->order('sort asc')->select();
	    $this->assign('link',$link);
//	      halt($gsjj);
	      
         return $this->fetch();
    }
    
    
}
